//2009/09/08 20:09:12
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class Packhorses
{
public:
    int horses(int p, int x, int y)
    {
        int ret = 10000;
        for (int i = 0; i<=p; i++)
        {
            int xx = max(0,x - i*2);
			//xx is the number of small bags remaining after
			//i horses are loaded with one person and two small bags.
            int yy = max(0,y - (p-i));
			//yy is the number of large bags remaining after
			//the other p-i horses are loaded with large bags.
            ret = min(ret, p + (xx+2)/3 + (yy+1)/2);
			//Note that (xx+2)/3 is just a way of taking the ceiling of xx/3. 
        }
        return ret;
    }

};
